package com.wcity.manage.dao.mapper;

import com.wcity.manage.dao.dal.BaseMapper;
import com.wcity.manage.dao.model.User;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 后台用户dao接口
 *
 * @author dy
 */
@Repository
public interface UserMapper  extends BaseMapper<User, Serializable>{

    /**
     * 根据用户名获取用户
     *
     * @param userName
     * @return
     */
    User findByUserName(@Param("userName") String userName);

    /**
     * 更新最后登录时间
     *
     * @param id
     * @param lastLoginTime
     * @return
     */
    @Update( " UPDATE td_manage_user SET `last_login_time` = #{lastLoginTime} WHERE id = #{id} " )
    int updateLastLoginTime(@Param("id") int id, @Param("lastLoginTime") Date lastLoginTime);

    /**
     * 获取所有用户
     * @return
     */
    @Select(" select id,work_no from td_manage_user ")
    List<User> findAll();

}
